home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / STRINGS / PACKAGE6 / RIGHT.DOC < prev    next >
Text File  |  1990-07-25  |  2KB  |  56 lines

  1. ------------------------------------------------------------------------------
  2. RightString
  3. ------------------------------------------------------------------------------
  4.  
  5.  
  6. declaration:     procedure RightString (    OriginalString:
  7.                                               TypeString;
  8.                                             NumberOfChracters:
  9.                                               integer;
  10.                                         var ResultString:
  11.                                               TypeString);
  12.  
  13. purpose:         Returns a portion of a string(original) in another
  14.                  string(result).
  15.  
  16. preconditions:   OriginalString was originally initiialized.
  17.                  NumberOfCharacters has been a given a meaningfull value.
  18.                  ResultString may be undifined.
  19.  
  20. postconditions:  ResultString is filled with the desired number of characters
  21.                  from the original string from left to right starting from
  22.                  the point were the number of characters is from the right
  23.                  to the left.
  24.  
  25. special cases:   -if NumberOfCharacters <= 0 then ResultString._Length is 0 and
  26.                   ResultString._PackedArray is not changed.
  27.                  -if NumberOfCharacters >= OriginalString._Length then
  28.                   ResultString = OriginalString.
  29.  
  30. example:         var
  31.                    OriginalString,
  32.                    ResultString:
  33.                      TypeString;
  34.                    NumberOfCharacters:
  35.                      integer;
  36.                    LastKey:
  37.                      TypeKey;
  38.  
  39.                  begin
  40.                    .
  41.                    .
  42.                    .
  43.                    ReadlnString (OriginalString, MaxStringLength, LastKey);
  44.                    NumberOfCharacters:= 5;
  45.                    RightString (OriginalString, NumberOfCharacters,
  46.                      ResultString);
  47.                    write(output,'The last five characters are ');
  48.                    WriteString(ResultString);
  49.                    writeln(output,'.')
  50.                    .
  51.                    .
  52.                    .
  53.                  end
  54.  
  55. ------------------------------------------------------------------------------
  56.